
package org.platform.tool.util;

import it.sauronsoftware.ftp4j.FTPDataTransferListener;
import lombok.extern.slf4j.Slf4j;

/**
 * FTP监听器,做了简单实现
 */
@Slf4j
public class FtpListener implements FTPDataTransferListener {

    public static FtpListener instance() {
        return new FtpListener();
    }

    @Override
    public void started() {
        log.debug("：FTP启动");
    }

    @Override
    public void transferred(int length) {
        log.debug("：FTP传输" + length);

    }

    public void transferred(long length, String fileName) {
        log.debug(fileName + "：FTP传输" + length);

    }

    public void transferred(long length, String fileName, double allLength) {

        String str = fileName.substring(fileName.length() - 1, fileName.length());
        if (str.equals("1")) {
            log.debug(fileName + "：FTP传输" + length + "/" + allLength);
        } else if (str.equals("2")) {
            log.debug(fileName + "：FTP传输" + length + "/" + allLength);
        }

    }

    @Override
    public void completed() {
        log.debug("：FTP完成");
    }

    public void completed(String fileName) {
        log.debug(fileName + "：FTP完成");
    }

    @Override
    public void aborted() {
        log.debug("：FTP中止");
    }

    @Override
    public void failed() {
        log.error("：FTP挂掉");
    }

}